
Imports System.IO

Public Module _show

    Public text As String = Nothing

    Public Sub main(ByVal args() As String)
        On Error Resume Next

        debugpause()

        If args.Length() = 0 Then
            raiseError("argument count error, input0 input1 ... inputN, if inputX is '/-', use console", _
                        errorHandle.errorType.critical)
        Else
            Dim reader As TextReader = Nothing
            Dim i As Int32

            For i = 0 To args.Length() - 1
                If args(i) = "/-" Then
                    reader = Console.In
                Else
                    reader = New StreamReader(New FileStream(args(0), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                End If
                assert(Not reader Is Nothing, "file no found, " + args(0))

                text += reader.ReadToEnd
                closestream(reader)
            Next

            Dim ui As New showUI
            ui.textbox.Text = text
            Application.Run(ui)
        End If
    End Sub
End Module
